import * as _ from 'lodash'
import { getUserInfo, getToken } from './Libs'

const domainUrl = "http://47.100.124.118"

//登录
export function loginUrl(params = {}) {
  const userName = params.userName
  const passWord = params.passWord
  return `${domainUrl}/api/login/login.api?userName=${userName}&passWord=${passWord}`
}

//详情通用页面
export function getLineAndMoney(params = {}) {
  const startTime = params.startTime
  const endTime = params.endTime
  const orgId = getUserInfo().orgId
  const useArea = params.useArea;
  return `${domainUrl}/api/detail/getLineAndMoney.api?startTime=${startTime}&endTime=${endTime}&orgId=${orgId}&useArea=${useArea}`
}

//  概述 + 预警
export function tmodeContentMsg(params = {}) {
  const startTime = params.startTime
  const endTime = params.endTime
  const orgId = getUserInfo().orgId
  const reportType = params.reportType
  const modeArea = params.modeArea
  return `${domainUrl}/api/tmode/getContentMsgs.api?startTime=${startTime}&endTime=${endTime}&orgId=${orgId}&modeAreas=${modeArea}&reportType=${reportType}`
}

// 首页 概述+预警  （新）
export function shouyeContentMsg (params = {}) {
  const startTime = params.startTime
  const endTime = params.endTime
  const orgId = getUserInfo().orgId
  const type = params.type
  return `${domainUrl}/api/tmode/getContentMsgsShouye.api?startTime=${startTime}&endTime=${endTime}&orgId=${orgId}&type=${type}`
}

export function tmodeContentMsgNew(params = {}) {
  const startTime = params.startTime
  const endTime = params.endTime
  const orgId = getUserInfo().orgId
  return `${domainUrl}/api/detail/homePage.api?startTime=${startTime}&endTime=${endTime}&orgId=${orgId}`
}

//w问题报告
export function problemReport(params ={}) {
  const startTime = params.startTime
  const endTime = params.endTime
  const orgId = getUserInfo().orgId
  return `${domainUrl}/api/divine/getQueReport.api?startTime=${startTime}&endTime=${endTime}&orgId=${orgId}`
}

export function tzycOne(params ={}) {
  const { tax, zcje, pay, fundsHand, oneIncome, srsy} = params
  return `${domainUrl}/api/divine/autoComp.api?tax=${tax}&zcje=${zcje}&pay=${pay}&fundsHand=${fundsHand}&oneIncome=${oneIncome}&srsy=${srsy}`
}

export function tzycTwo(params = {}) {
  let str = ""
  _.map(params, (v, k) => {
    str += k + "=" + v + "&"
  })

  return `${domainUrl}/api/divine/getTzDivine.api?` + str
}

// 资产负债表主页信息
export function assetLiabilityMainMsg( params = {}) {
  const startTime = params.startTime
  const endTime = params.endTime
  const orgId = getUserInfo().orgId
  return `${domainUrl}/api/tBasiAssetsAndLiabilities/getTotalTbasiAssets.api?startTime=${startTime}&endTime=${endTime}&orgId=${orgId}&token=${getToken()}`
}

// 资产负债表详情信息
export function assetLiabilityDetailMsg(params = {}) {
  const startTime = params.startTime
  const endTime = params.endTime
  const orgId = getUserInfo().orgId
  return `${domainUrl}/api/tBasiAssetsAndLiabilities/getDetailTbasiAssets.api?startTime=${startTime}&endTime=${endTime}&orgId=${orgId}&token=${getToken()}`
}

// 资产负债模型对比
export function assetLiabilityModelCompare(params = {}) {
  const startTime = params.startTime
  const endTime = params.endTime
  const orgId = getUserInfo().orgId
  return `${domainUrl}/api/tBasiAssetsAndLiabilities/getLine.api?startTime=${startTime}&endTime=${endTime}&orgId=${orgId}&token=${getToken()}`
}

//利润表首页接口
export function profitMainMsg(params = {}) {
  const startTime = params.startTime;
  const endTime = params.endTime;
  const orgId = getUserInfo().orgId;
  return `${domainUrl}/api/profit/getProfitMainMsg2.api?startTime=${startTime}&endTime=${endTime}&orgId=${orgId}&token=${getToken()}`
}

export function profitCompare(params = {}) {
  const startTime = params.startTime;
  const endTime = params.endTime;
  const useArea = params.useArea;
  const orgId = getUserInfo().orgId;
  return `${domainUrl}/api/profit/getLine.api?startTime=${startTime}&endTime=${endTime}&orgId=${orgId}&useArea=${useArea}&token=${getToken()}`
}

//利润表明细接口
export function profitDetailMsg(params = {}) {
  const startTime = params.startTime;
  const endTime = params.endTime;
  const orgId = getUserInfo().orgId
  return `${domainUrl}/api/profit/getProfitDetailMsg2.api?startTime=${startTime}&endTime=${endTime}&orgId=${orgId}&token=${getToken()}`
}

//利润表主要指标变更查询接口
export function profitMainChangeSearch(params = {}) {
  const startTime = params.startTime
  const endTime = params.endTime
  const orgId = getUserInfo().orgId;
  const searchCode = params.searchCode || ""
  return `${domainUrl}/api/profit/profitMainChangeSearch.api?startTime=${startTime}&endTime=${endTime}&orgId=${orgId}&token=${getToken()}&searchCode=${searchCode}`
}

//现金流量表首页接口
export function cashFlowMainMsg(params = {}) {
  const startTime = params.startTime;
  const endTime = params.endTime;
  const orgId = getUserInfo().orgId;
  return `${domainUrl}/api/cashFlow/getCashFlowMainMsg2.api?startTime=${startTime}&endTime=${endTime}&orgId=${orgId}&token=${getToken()}`
}

//现金流量表明细接口
export function cashFlowDetailMsg(params = {}) {
  const startTime = params.startTime;
  const endTime = params.endTime;
  const orgId = getUserInfo().orgId;
  return `${domainUrl}/api/cashFlow/getCashFlowDetailMsg.api?startTime=${startTime}&endTime=${endTime}&orgId=${orgId}&token=${getToken()}`
}

export function cashFlowMainHistogram(params ={}) {
  const startTime = params.startTime;
  const endTime = params.endTime;
  const useArea = params.useArea;
  const orgId = getUserInfo().orgId;
  return `${domainUrl}/api/cashFlow/getCylinder.api?startTime=${startTime}&endTime=${endTime}&useArea=${useArea}&orgId=${orgId}&token=${getToken()}`
}

//现金流量表主要指标变更查询接口
export function cashFlowMainChangeSearch(params = {}) {
  const startTime = params.startTime;
  const endTime = params.endTime;
  const orgId = getUserInfo().orgId;
  const searchCode = params.searchCode || ""
  return `${domainUrl}/api/cashFlow/getCashFlowDetailMsg.api?startTime=${startTime}&endTime=${endTime}&orgId=${orgId}&token=${getToken()}&searchCode=${searchCode}`
}

//咨询列表
export function newsList(params = {}) {
  const userId = getUserInfo().id
  const pageId = params.currentPage
  const clzz = params.clzz
  return `${domainUrl}/api/msg/catalog.api?userId=${userId}&pageId=${pageId}&clzz=${clzz}`
}

export function dubangAnalyze(params = {}) {
  const startTime = params.startTime;
  const endTime = params.endTime;
  const orgId = getUserInfo().orgId;
  return `${domainUrl}/api/tmode/getDbMsg.api?startTime=${startTime}&endTime=${endTime}&orgId=${orgId}&token=${getToken()}`
}

//比率分析详情
export function rateAnalyzeDetail(params = {}) {
  const startTime = params.startTime;
  const endTime = params.endTime;
  const orgId = getUserInfo().orgId;
  return `${domainUrl}/api/detail/bilv.api?startTime=${startTime}&endTime=${endTime}&orgId=${orgId}&token=${getToken()}`
}

//顾问咨询
export function consultantDetail(params = {}) {
  const type = params.type
  const pageId = params.currentPage;
  const userId = getUserInfo().id;
  const projectId = params.projectId
  return `${domainUrl}/api/msg/message.api?type=${type}&projectId=${projectId}&pageId=${pageId}&userId=${userId}&token=${getToken()}`
}

export function consultantSecondDetail(params = {}) {
  return `${domainUrl}/api/msg/project.api`
}

export function submitNewMessage(params = {}) {
  params.userId = getUserInfo().id
  return `${domainUrl}/api/msg/insertMessage.api?type=${params.type}&projectId=${params.projectId}&content=${params.content}&userId=${params.userId}`
}

//预测
export function forecast(params = {}) {
  const startTime = params.startTime;
  const endTime = params.endTime;
  const orgId = getUserInfo().orgId;
  return `${domainUrl}/api/divine/getDivine.api?startTime=${startTime}&endTime=${endTime}&orgId=${orgId}&token=${getToken()}`
}
